package com.geekyang.rabbitmqapi.myconsumer;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;

import java.io.IOException;

/**
 * @author ccyang
 * @date 2018/10/14 14:03
 * 自定义消费者，更优雅的方式
 */
public class MyConsumer extends DefaultConsumer{

    public MyConsumer(Channel channel) {
        super(channel);
    }

    @Override
    public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
                               byte[] body) throws IOException {
        System.err.println("-------------consumer message-------------");
        System.err.println("consumerTag：" + consumerTag);
        System.err.println("envelope：" + envelope);
        System.err.println("properties：" + properties);
        System.err.println("body：" + new String(body));
    }
}
